﻿using AutoMapper;
using B.S.Filtration.Domain;
using B.S.Filtration.Domain.专检;
using B.S.Filtration.ErrorCode;
using B.S.Filtration.Read.Api.Application.Command.ProductionTaskCommand;
using MediatR;
using SqlSugar;

namespace B.S.Filtration.Read.Api.Application.CommandHander.ProductionTaskHandler
{
    public class FTProductionTaskHandler : IRequestHandler<FTProductionTaskCommand, APIResult<List<ProductionTask>>>
    {
        private readonly ISqlSugarClient db;
        private readonly IMapper mapper;
        public FTProductionTaskHandler(ISqlSugarClient db, IMapper mapper)
        {
            this.db = db;
            this.mapper = mapper;
        }
        public async Task<APIResult<List<ProductionTask>>> Handle(FTProductionTaskCommand request, CancellationToken cancellationToken)
        {
            APIResult<List<ProductionTask>> result = new APIResult<List<ProductionTask>>();
            var list = await db.Queryable<ProductionTask>().Where(x => x.IsDel == false && x.id == request.id).ToListAsync();
            result.data = list;
            result.code = APIResultCode.success;
            result.msg = "专检申请显示成功";
            return await Task.FromResult(result);
        }
    }
}
